package com.start.boot.adquery;

import com.start.boot.query.Query;
import com.start.boot.service.AdvanceQueryService;
import com.start.boot.utils.TyywQueryUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 高级查询，返回结果
 *
 * @caomin
 * @create 2017-12-14 10:11
 **/
@Component
public class AdvanceQueryResult {

    @Autowired
    TyywQueryUtils tyywQueryUtils;

    @Autowired
    AdvanceQueryService advanceQueryService;



    public  List<String> getAnYouQueryResult(Map<String,Object> parmarters) throws Exception {

            Query query = new Query();
            HashMap<String, String> disPlayName = new HashMap<>();
            disPlayName.put("BMSAH","BMSAH");
            Query.Criteria criteria = query.setTableName("tyyw_gg_ajjbxx").setDisplayColumnName(disPlayName)
                    .createCriteria()
                    .andEqualTo("sfsc", "N");
            //拼装条件
            for (Map.Entry<String, Object> par : parmarters.entrySet()) {
                Object value = par.getValue();
                if (value instanceof String){
                    criteria.andEqualTo(par.getKey(), (String) value);
                }else if (value instanceof  List){
                    criteria.andin(par.getKey(), (List<String>) value);
                }
            }
        List selected = tyywQueryUtils.getSelected(query.build());
        return null;
    }
}
